import React from 'react';
import CommonList from '../../../components/CommonLists/list';
import HideOrShowText from '../../../components/HideOrShowText';
import CopyToClipboard from '../../../components/CopyToClipboard';
import { Tooltip } from 'antd';
class TemplateLists extends CommonList {
  constructor(props) {
    super(props);
    this.api = 'application';
    this.tableClass = '';
    this.delButton = false;
    this.tableParams = {
      rowKey: 'app_id'
    };
    this.columns = [  
      {
        title: '编号',
        dataIndex: 'app_id',
        key: 'app_id',
        width: 0
      },
      {
        title: '渠道名',
        key: 'app_name',
        dataIndex: 'app_name',
        ellipsis: true,
        render: text => {
          return (
            <Tooltip title={text} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {text}
              </div>
            </Tooltip>
          );
        }
      },
      {
        title: '所属部门',
        dataIndex: 'dept_name',
        key: 'dept_name',
        ellipsis: true
      },
      {
        title: 'AppKey',
        dataIndex: 'app_key',
        key: 'app_key',
        ellipsis: true,
        render: text => {
          return (
            <Tooltip title={text} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {text}
              </div>
              <CopyToClipboard text={text}></CopyToClipboard>
            </Tooltip>
          );
        }
      },
      {
        title: 'AppSecret',
        dataIndex: 'app_secret',
        key: 'app_secret',
        ellipsis: true,
        render: (text, record) => {
          return (
            <div>
              <HideOrShowText text={text} />
            </div>
          );
        }
      },
      {
        title: '描述',
        dataIndex: 'remark',
        key: 'remark',
        ellipsis: true,
        width: '20%',
        render: (text, record) => {
          return (
            <Tooltip title={text} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {text}
              </div>
            </Tooltip>
          );
        }
      },
      {
        title: '创建/修改人',
        dataIndex: 'create_user_name',
        key: 'create_user_name',
        ellipsis: true,
        render: (text, record) => {
          var content = !!record.update_user_name
            ? `${record.create_user_name}/${record.update_user_name}`
            : `${record.create_user_name}/${record.create_user_name}`;
          return <>{content}</>;
        }
      },
      {
        title: '修改时间',
        dataIndex: 'update_time',
        key: 'update_time',
        ellipsis: true,
        width: 150,
        render: (text, record) => {
          var content = !!record.update_time ? record.update_time : record.create_time;
          return (
            <Tooltip title={content} placement='topLeft'>
              <div className='overflowtext' style={{ width: '100%' }}>
                {content}
              </div>
            </Tooltip>
          );
        }
      }
    ];
  }
  componentDidMount() {}

  // 删除时的参数
  getDeleteParam = record => {
    return { app_id: record.app_id };
  };
}

export default TemplateLists;
